package com.itheima.d1_collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionTest1 {
    public static void main(String[] args) {
        //collection集合的特点
        //List集合的特点:添加的元素是有序的,可以重复，有索引
        //Set集合的特点:添加的元素是无序的,不可以重复，没有索引
        //collection集合的常用方法
        Collection<String> c = new ArrayList<>();
        c.add("aaa");
        c.add("bbb");
        System.out.println(c);

        c.clear();
        System.out.println(c);
        c.add("aaa");

        c.isEmpty();
        System.out.println(c);

        c.size();
        System.out.println(c);

        System.out.println(c.contains("aaa"));

        c.remove("aaa");
        System.out.println(c);

        Object[] objects = c.toArray();
        System.out.println(Arrays.toString(objects));

        System.out.println("-----------------");

        Collection<String> c1 = new ArrayList<>();
        c1.add("aaa");
        c1.add("bbb");
        Collection<String> c2 = new ArrayList<>();
        c2.add("ccc");
        c2.add("ddd");

        //合并两个集合
        c1.addAll(c2);
        System.out.println(c1);
        System.out.println(c2);


    }
}
